<template>
    <div class="indexshow">
    		
    		
			<Row style="margin-top: 20px;margin-bottom: 20px;">
		        <Col span="6">
		        	<span>学年：</span>
					<Select v-model="studyYearSelect" style="width:150px" @on-change="studyYearSelectChange">
				        <Option v-for="item in studyYearList" :value="item.value" :key="item.value">{{ item.label }}</Option>
				    </Select>
		        </Col>
		        <Col span="6">
		        	<span>科目：</span>
					<Select v-model="subjectselect" style="width:150px" @on-change="changeselect">
				        <Option v-for="item in subjectlist" :value="item.value" :key="item.value">{{ item.label }}</Option>
				    </Select>
		        </Col>
		    </Row>
			
			<div style="width: 100%;height: 20px;background-color: #ebedf0;"></div>
			<Row style="text-align: left;margin-top: 41px;">
				<Col span="12" style="text-align: left;">
	    			<span style="border-left: 5px solid #517EDB;font-size: 16px;"></span>
	    			<span style="font-size: 16px;font-weight: 800;margin-left: 41px;">评价达标率</span>
	    			<span style="font-size: 14px;margin-left: 12px;color: rgba(102, 102, 102, 0.61);">评价达标率=达标次数/评价总次数</span>
	    		</Col>
    			
		        
			</Row >
			
			<Row style="text-align: left;margin-top: 5px;margin-bottom: 50px;">
				<div id="myChart" ref="bar" :style="{width: '95%', height: '450px'}"></div>
			</Row >
			
			
			
			<!--柱状图  评价均差率-->
			<div style="width: 100%;height: 20px;background-color: #ebedf0;"></div>
			
			<Row style="text-align: left;margin-top: 41px;">
				<Col span="12" style="text-align: left;">
	    			<span style="border-left: 5px solid #517EDB;font-size: 16px;"></span>
	    			<span style="font-size: 16px;font-weight: 800;margin-left: 41px;">评价均差统计</span>
	    			<span style="font-size: 14px;margin-left: 12px;color: rgba(102, 102, 102, 0.61);">均差=教师评价值  - 平均评价值</span>
	    		</Col>
    			
		       </Col>
			</Row >
			
			
			
			<Row style="text-align: left;margin-top: 5px;margin-bottom: 50px;">
				<div id="myChart" ref="bar_standard" :style="{width: '95%', height: '450px'}"></div>
			</Row >
			<Row style="text-align: left;margin-top: 41px;">
				<Col span="12" style="text-align: left;">
	    			<span style="border-left: 5px solid #517EDB;font-size: 16px;"></span>
	    			<span style="font-size: 16px;font-weight: 800;margin-left: 41px;">评价均差人数统计</span>
	    		</Col>
			</Row >
			<Row style="text-align: left;margin-top: 5px;margin-bottom: 50px;">
				<div>
					<Row  style="margin:0 auto;margin-left:20px;margin-right:20px;margin-top:20px;margin-bottom:5px;color: #666666;border-radius: 12px;background-color: #f0f8ff;">
				        <Col v-for="item in teacherDeviationData_top" :key="item" :span="24/teacherDeviationData_top.length" style="text-align: center;">
							<span style="font-size: 16px;">{{item}}</span>
						</Col>
					</Row>
					<Row   style="margin:0 auto;color: #666666;margin: 5px 20px 5px 20px;padding:5px 0px 5px 0px;border-bottom: 1px solid rgb(240, 248, 255);">
				        <Col v-for="(item,index) in teacherDeviationData_data" :key="index" :span="24/teacherDeviationData_data.length" style="text-align: center;">
							<span style="font-size: 16px;">{{item}}人&nbsp;</span>
						</Col>
					</Row>
			    </div>
			</Row >
			
			
			<!--折线图-->
			<div style="width: 100%;height: 20px;background-color: #ebedf0;"></div>
    		<Row style="text-align: left;margin-top: 41px;">
    			<Col span="12" style="text-align: left;">
	    			<span style="border-left: 5px solid #517EDB;font-size: 16px;"></span>
	    			<span style="font-size: 16px;font-weight: 800;margin-left: 41px;">评价趋势图</span>
	    			&nbsp;&nbsp;&nbsp;&nbsp;
	    			
		       </Col>
			</Row >
			<Row style="text-align: left;margin-top: 10px;">
    			<Col span="24" style="text-align: left;margin-left:48px;">
    				<span>模式筛选：</span>
    				<ButtonGroup >
				        <Button v-bind:class="[linedata.legend.selectedMode == 'single'?buttonActiveClass:'']" @click="toggleLine('single')">单折线</Button>
				        <Button v-bind:class="[linedata.legend.selectedMode == 'multiple'?buttonActiveClass:'']" @click="toggleLine('multiple')">多折线</Button>
				    </ButtonGroup>
		       </Col>
			</Row >
			
			
			
			<Row v-if="linedata.legend.selectedMode == 'single'?true:false" style="text-align: left;margin-top: 10px;">
		        <Col span="23" style="text-align: left;margin-left:48px;">
			        <span>教师筛选：</span>
		        	<RadioGroup  v-model="teacherselect" type="button" @on-change="changeteacherselect">
		        		<Radio v-for="item in teacherlist" :key="item.value" :label="item.value">{{item.label}}</Radio>
				       
				    </RadioGroup>
		        </Col>
			</Row >
			
			
			
			<div >
		    	<Row style="text-align: left;margin-top: 30px;padding-bottom: 20px;">
						<div>
			    			<!--<p style="font-size: 16px;font-weight: 600;margin-left: 45px;text-align: left;">语文科：</p>-->
			    		</div>
						<div id="myChart" ref="line" :style="{width: '95%', height: '450px',margin:'0 auto'}"></div>
				</Row >
			</div>
			
        
    </div>
</template>

<script>
	import api from "@/components/js/Apidomain.js"
	import { getsessionstorage } from '@/components/js/Localstorage'
	import axios from 'axios'
//	const CancelToken = axios.CancelToken;
//	const source = CancelToken.source();
    export default {
        data() {
            return {
            	source:null,
            	
            	studyYearSelect:"",		//学年选择
            	studyYearList:[],		//学年列表
            	
            	teacherDeviationData_top:[],		//评价均差统计的顶部
            	teacherDeviationData_data:[],		//评价均差统计的值
            	
            	loadingShow:false,				//表格获取的加载中显示隐藏
            	subjectlistshow:false,			//科目选择列表的加载中显示隐藏
            	chartshow:false,				//chart的显示加载中
            	subjectselect:"",				//选择的科目
            	subjectselect1:"",				//折线图选择的科目
            	subjectselect2:"",				//评价均差率选择的科目
            	subjectselect4:"",
            	teacherselect:"",
				subjectlist: [
//					{value: '1',label: '语文'},
                ],
                teacherlist:[],
                
                linedata:{
				    title: {
				        text: '',
				        textStyle:{
				        	fontSize:"15",
				        }
				    },
				    tooltip: {
				        trigger: 'axis'
				    },
				    legend: {
//				        data:['邮件营销','联盟广告','视频广告','直接访问','搜索引擎']
						show:false,
						selectedMode: 'single',		//多选单选模式
						selected: {}
				    },
				    grid: {
				        left: '3%',
				        right: '4%',
				        bottom: '2%',
				        top:'20%',
				        containLabel: true
				    },
//				    toolbox: {
//				        feature: {
//				            saveAsImage: {}
//				        }
//				    },
				    xAxis: {
				        type: 'category',
				        boundaryGap: false,
				        data: "",
//				        data: ['周一','周二','周三','周四','周五','周六','周日']
						axisTick: {
			                alignWithLabel: true
			            },
			            axisLabel: {
                                            interval: 0,
                                            formatter:function(value)
                                            {
                                                
                                                var ret = "";//拼接加\n返回的类目项
                                                var maxLength = 5;//每项显示文字个数
                                                var valLength = value.length;//X轴类目项的文字个数
                                                var rowN = Math.ceil(valLength / maxLength); //类目项需要换行的行数
                                                if (rowN > 1)//如果类目项的文字大于3,
                                                {
                                                    for (var i = 0; i < rowN; i++) {
                                                        var temp = "";//每次截取的字符串
                                                        var start = i * maxLength;//开始截取的位置
                                                        var end = start + maxLength;//结束截取的位置
                                                        //这里也可以加一个是否是最后一行的判断，但是不加也没有影响，那就不加吧
                                                        temp = value.substring(start, end) + "\n";
                                                        ret += temp; //凭借最终的字符串
                                                    }
                                                    return ret;
                                                }
                                                else {
                                                    return value;
                                                }
                                            }
                                        }

				    },
				    yAxis: {
				        type: 'value',
				        min: function(value) {
						    return parseInt(value.min) ;
						}
				    },
				    series: [
//				    	{
//				            name:'邮件营销',
//				            type:'line',
//				            data:[120, 132, ]
//				        }, 
				    ]
				},
				
				
				
				//柱状图
				bar:{
				    color: ['#3398DB'],
				    tooltip : {
				        trigger: 'axis',
				        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
				            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
				        }
				    },
				    grid: {
				        left: '3%',
				        right: '2%',
				        bottom: '3%',
				        containLabel: true
				    },
				    xAxis : [
				        {
				        	splitLine:{show: false},//去除网格线
				            type : 'category',
				            data : "",
//				            data : ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun','Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
				            axisTick: {
				                alignWithLabel: true
				            },
				            axisLabel: {
                                           interval:0,
                                           rotate:-40
                                       }
				            
				        }
				    ],
				    yAxis : [
				        {
				        	name : '百分比',
//				        	splitLine:{show: false},//去除网格线
				            type : 'value',
				            axisLabel:{
				            	textStyle: {
			                    	fontSize: 16 ,
			                   	},
				            	formatter:'{value} %'
				            },
				            
				        }
				    ],
				    series : [
				        {
				            name:'数据',
				            type:'bar',
				            barWidth: '20%',
				            data:"",
//				            data:[10, 52, 200, 334, 390, 330, 220,100, 152, 200, 334, 390, 330, 220]
							label: {
					            "normal": {
					                "show": true,
					                "textStyle": {
					                    "fontSize": 12
					                },
					                formatter:'{c} %'
					            },
							},
				        }
				    ]
				},
				//柱状图
				bar_standard:{
				    color: ['#3398DB'],
				    tooltip : {
				        trigger: 'axis',
				        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
				            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
				        }
				    },
				    grid: {
				        left: '3%',
				        right: '2%',
				        bottom: '3%',
				        containLabel: true
				    },
				    xAxis : [
				        {
				        	splitLine:{show: false},//去除网格线
				            type : 'category',
				            data : "",
//				            data : ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun','Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
				            axisTick: {
				                alignWithLabel: true
				            },
				            axisLabel: {
                                           interval:0,
                                           rotate:-40
                                       }
				            
				        }
				    ],
				    yAxis : [
				        {
				        	name : '',
//				        	splitLine:{show: false},//去除网格线
				            type : 'value',
				            axisLabel:{
				            	textStyle: {
			                    	fontSize: 16 ,
			                   	},
				            	formatter:'{value}'
				            },
				            
				        }
				    ],
				    series : [
				        {
				            name:'数据',
				            type:'bar',
				            barWidth: '20%',
				            data:"",
//				            data:[10, 52, 200, 334, 390, 330, 220,100, 152, 200, 334, 390, 330, 220]
							label: {
					            "normal": {
					                "show": true,
					                "textStyle": {
					                    "fontSize": 12
					                },
					                formatter:'{c}'
					            },
							},
				        }
				    ]
				},
				
				//饼图部分数据 =》 改为柱状图
				teacherDeviationData:{
					title: {
				        text: '教师均差值统计',
//				        subtext: '虚构数据',
				        left: 'left',
				        textStyle:{
				        	fontSize:"15",
				        }
				    },
					tooltip : {
				        trigger: 'axis',
				        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
				            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
				        }
				    },
				    grid: {
				        left: '2%',
				        right: '2%',
				        bottom: '10%',
				        top:'20%',
				        containLabel: true
				    },
				    xAxis : [
				        {
				        	splitLine:{show: false},//去除网格线
				            type : 'category',
				            data : "",
//				            data : ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun','Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
				            axisTick: {
				                alignWithLabel: true
				            },
				            axisLabel: {
                                           interval:0,
                                           rotate:-40
                                       }
				            
				        }
				    ],
				    yAxis : [
				        {
				        	name : '',
//				        	splitLine:{show: false},//去除网格线
				            type : 'value',
				            axisLabel:{
				            	textStyle: {
			                    	fontSize: 16 ,
			                   	},
				            	formatter:'{value}'
				            },
				            
				        }
				    ],
				    series : [
				        {
				            name:'数据',
				            type:'bar',
				            barWidth: '20%',
				            data:"",
//				            data:[10, 52, 200, 334, 390, 330, 220,100, 152, 200, 334, 390, 330, 220]
							label: {
					            "normal": {
					                "show": true,
					                "textStyle": {
					                    "fontSize": 12
					                },
					                formatter:'{c}'
					            },
							},
				        }
				    ]
					
					
//				    title: {
//				        text: '教师均差值统计',
////				        subtext: '虚构数据',
//				        left: 'left',
//				        textStyle:{
//				        	fontSize:"15",
//				        }
//				    },
//				    tooltip : {
//				        trigger: 'item',
//				        formatter: "{a} <br/>{b} : {c}人 ({d}%)"
//				    },
//				    legend: {
//				        // orient: 'vertical',
//				        // top: 'middle',
//				        bottom: 10,
//				        left: 'center',
//				        data: "",
////				        data: ['西凉', '益州','兖州','荆州','幽州']
//						
//				    },
//				    series : [
//				        
//				        {
//				        	name:'人数',
//				            type: 'pie',
//				            radius: ['20%', '60%'],
//				             center: ['50%', '45%'],
//				            selectedMode: 'single',
//				            label: {
//				                normal: {
//				                    formatter: '{per|{d}%}\n \n  {b|{b}：}{c}人',
//				                    rich: {},
//				                    textStyle: {
//					                    "fontSize": 14
//					                }
//				                }
//				            },
//				            data:[
////				                {value:1548,name: '幽州'},
////				                {value:535, name: '荆州'},
////				                {value:510, name: '兖州'},
////				                {value:634, name: '益州'},
////				                {value:735, name: '西凉'}
//				            ],
//				            itemStyle: {
//				                emphasis: {
//				                    shadowBlur: 10,
//				                    shadowOffsetX: 0,
//				                    shadowColor: 'rgba(0, 0, 0, 0.5)'
//				                }
//				            }
//				        }
//				    ]
				},
				teacherData:{
				    title: {
				        text: '教师数据',
//				        subtext: '虚构数据',
				        left: 'left',
				        textStyle:{
				        	fontSize:"15",
				        }
				    },
				    tooltip : {
				        trigger: 'item',
				        formatter: "{a} <br/>{b} : {c}人 ({d}%)"
				    },
//				    grid: {
//				        left: '2%',
//				        right: '2%',
//				        bottom: '10%',
//				        top:'20%',
//				        containLabel: true
//				    },
				    legend: {
				        // orient: 'vertical',
				        // top: 'middle',
				        bottom: 10,
				        left: 'center',
				        data: "",
				        
				    },
				    series : [
				        
				        {
				        	name:'科目',
				            type: 'pie',
				            radius: ['20%', '50%'],
				             center: ['50%', '45%'],
				            selectedMode: 'single',
				            label: {
				                normal: {
				                    formatter: '{per|{d}%}\n \n  {b|{b}：}{c}人',
				                    rich: {},
				                    textStyle: {
					                    "fontSize": 14
					                }
				                }
				                
				            },
				            data:[
//				                {value:1548,name: '幽州'},
				            ],
				            itemStyle: {
				                emphasis: {
				                    shadowBlur: 10,
				                    shadowOffsetX: 0,
				                    shadowColor: 'rgba(0, 0, 0, 0.5)'
				                }
				            }
				        }
				    ]
				},
            }
        },
        created(){
        	
		},
        mounted() {
        	this.getStudyYearList()
//        	this.getsubjectlist();
        },
        computed:{
			buttonActiveClass: function() {
				return 'active'
			},
			selectedMode:function(){
				return this.linedata.legend.selectedMode;
			}
        },
        methods: {
        	//获取学年选择列表
           	getStudyYearList:function(){
           		var self = this;
            	let url = api.apidomain+'/tqes/web/quaTeacherResults/getSchoolYearByExam';
            	this.$http.post(url,{"type":"Middle"}).then(function(response) {
					if(response.data.success == true){
//						console.log(response.data.data)
						self.studyYearList = response.data.data
						if(self.studyYearList.length != 0){
							self.studyYearSelect = self.studyYearList[0].value;
							self.getsubjectlist();
						}
		            }else if(response.data.success == false){
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
		            	}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00218',
							duration: 10,
							closable: true
						});
					});
           	},
       		studyYearSelectChange:function(){
//         		this.getSubjectList()
				
				//评价达标率
				this.getbarchartdata();
				//评价均差统计 
				this.getbarchartdata_standard();
				//评价均差人数统计
				this.getpiechartdata2();
				//获取单折线老师
				this.linedata.legend.selectedMode = "single";
				this.linedata.legend.show = false;
				this.getteacherlist();
				
           	},
           	getsubjectlist:function(){
//         		this.subjectlistshow = true;
				let sessionroleid = getsessionstorage('roleid');
           		var self = this;
            	let url = api.apidomain+'/tqes/web/quaPerformance/getSubjectByAd/'+sessionroleid;
            	this.$http.post(url, {}).then(function(response) {
					if(response.data.success == true){
//						////console.log(response.data.data)
						self.subjectlist = response.data.data
						if(self.subjectlist.length != 0){
							self.subjectselect = self.subjectlist[0].value;
							self.getbarchartdata();
							self.getbarchartdata_standard();
							self.getteacherlist()
							self.getpiechartdata2();
						}
						
						
						self.subjectlistshow = false;
		            }else if(response.data.success == false){
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
//		            		self.subjectlistshow = false;
		            	}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00219',
							duration: 10,
							closable: true
						});
//						self.subjectlistshow = false;
					});
           	},
           
        	
        	//折线图显示单选多选
        	toggleLine:function(type){
        		if(type == "single"){
        			this.linedata.legend.selectedMode = "single";
        			this.linedata.legend.show = false;
        			this.getteacherlist()
//      			this.drawLine()
        		}else if(type == "multiple"){
        			this.linedata.legend.selectedMode = "multiple"
        			this.linedata.legend.show = true;
        			this.getlinechartdata()
//      			this.drawLine()
        		}
        		
        	},
        	drawLine() {
        		this.$nextTick(function () {
	                let myChart = this.$echarts.init(this.$refs.line,'hengyi')
	                myChart.clear();
	                myChart.setOption(this.linedata);
                })
           	},
            //柱状图
            drawBar() {
            	this.$nextTick(function () {
	                let myChart = this.$echarts.init(this.$refs.bar,'hengyi')
	                myChart.clear();
	                myChart.setOption(this.bar);
                })
            },
            drawBar_standard() {
            	this.$nextTick(function () {
	                let myChart = this.$echarts.init(this.$refs.bar_standard,'hengyi')
	                myChart.clear();
	                myChart.setOption(this.bar_standard);
                })
            },
            //更改科目选择后触发函数
        	changeselect:function(){
				//评价达标率
				this.getbarchartdata();
				//评价均差统计 
				this.getbarchartdata_standard();
				//评价均差人数统计
				this.getpiechartdata2();
				//获取单折线老师
				if(this.linedata.legend.selectedMode == "single"){
					this.getteacherlist()
        		}else if(this.linedata.legend.selectedMode == "multiple"){
        			this.getlinechartdata();
        		}
			},
//			
			//改变教师后执行的函数
			changeteacherselect:function(){
				this.getsinglelinechartdata()
			},
			cancel:function(){
				this.source.cancel('stop');
			},
			//评价达标率
			getbarchartdata:function(){
				let sessionroleid = getsessionstorage('roleid');
				
				var senddata = {
					"adName":this.subjectselect,
					"roleId":sessionroleid,
					"type":"Middle",
					"schoolYear":this.studyYearSelect
				}
				
				var self = this;
            	let url = api.apidomain+'/tqes/web/quaTeacherResults/getTeacherQualifiedRateBySchoolYear';
            	this.$http.post(url,senddata).then(function(response) {
					if(response.data.success == true){
//						////console.log(response.data.data)
						self.bar.xAxis[0].data = response.data.data.name;
						self.bar.series[0].data = response.data.data.score; 
//						//$nexttick为了使tch = true生效（dom）变化后再执行drawline，这样才不会有报错误
						self.$nextTick(function () {
							self.drawBar()
						})
	            }else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
	            	}
				})
				.catch(function(error) {
					self.$Message.error({
							content: '系统发生错误：错误码00220',
							duration: 10,
							closable: true
					});
				});
			},
			//评价均差统计 
			getbarchartdata_standard:function(){
				let sessionroleid = getsessionstorage('roleid');
				
				var senddata = {
					"adName":this.subjectselect,
					"roleId":sessionroleid,
					"type":"Middle",
					"schoolYear":this.studyYearSelect
				}
				
				var self = this;
            	let url = api.apidomain+'/tqes/web/quaTeacherResults/getTeacherAverageDValueBySchoolYear';
            	this.$http.post(url,senddata).then(function(response) {
					if(response.data.success == true){
//						////console.log(response.data.data)
						self.bar_standard.xAxis[0].data = response.data.data.name;
						self.bar_standard.series[0].data = response.data.data.strDValue; 
//						//$nexttick为了使tch = true生效（dom）变化后再执行drawline，这样才不会有报错误
						self.$nextTick(function () {
							self.drawBar_standard()
						})
	            }else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
	            	}
				})
				.catch(function(error) {
					self.$Message.error({
							content: '系统发生错误：错误码00221',
							duration: 10,
							closable: true
						});
//					self.chartshow = false;
				});
			},
			//评价均差人数统计
			getpiechartdata2:function(){
//				this.chartshow = true;
				let sessionroleid = getsessionstorage('roleid');
				
				var senddata = {
					"adName":this.subjectselect,
					"roleId":sessionroleid,
					"type":"Middle",
					"schoolYear":this.studyYearSelect
				}
				
				var self = this;
            	let url = api.apidomain+'/tqes/web/quaTeacherResults/getTeacherAverageDValueNumBySchoolYear';
            	this.$http.post(url,senddata).then(function(response) {
					if(response.data.success == true){
						self.teacherDeviationData_top = response.data.data.name;
						self.teacherDeviationData_data = response.data.data.value;
	            }else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
//	            		self.chartshow = false;
	            	}
				})
				.catch(function(error) {
					self.$Message.error({
							content: '系统发生错误：错误码00222',
							duration: 10,
							closable: true
						});
//					self.chartshow = false;
				});
			},
			//获取多折线图数据
			getlinechartdata:function(){
				this.source = axios.CancelToken.source();
				let sessionroleid = getsessionstorage('roleid');
				
				var senddata = {
					"type":"Middle",
					"schoolYear":this.studyYearSelect,
					"adName":this.subjectselect,
					"roleId":sessionroleid
				}
				
				var self = this;
            	let url = api.apidomain+'/tqes/web/quaTeacherResults/getTeacherResultsAllBySchoolYear';
            	axios.post(url,senddata,{cancelToken: this.source.token}).then(function(response) {
					if(response.data.success == true){
//						////console.log(response.data.data)

						for(let i = 0;i<response.data.data.Subject_data.length;i++){
							if(i == 0){
								self.linedata.legend.selected[response.data.data.Subject_data[i].name] = true;
							}else{
								self.linedata.legend.selected[response.data.data.Subject_data[i].name] = false;
							}
						}
						
						self.linedata.xAxis.data = response.data.data.Subject;
						self.linedata.series = response.data.data.Subject_data;
//						//console.log("执行到这里")
//						//$nexttick为了使tch = true生效（dom）变化后再执行drawline，这样才不会有报错误
//						self.$nextTick(function () {
							self.drawLine()
//						})
	            	}else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
//	            		self.chartshow = false;
	            	}
				})
				.catch(function(thrown) {
//					if (axios.isCancel(thrown)) {
//					    //console.log('Request canceled', thrown.message);
//					}else{
//						self.$Message.error('系统发生错误123');
	//					self.chartshow = false;
//					}
				});
			},
			//获取单折线数据
			getsinglelinechartdata:function(){
				this.source = axios.CancelToken.source();
				let sessionroleid = getsessionstorage('roleid');
				
				var senddata = {
					"teacherId":this.teacherselect,
					"type":"Middle",
					"schoolYear":this.studyYearSelect
				}
				
				var self = this;
            	let url = api.apidomain+'/tqes/web/quaTeacherResults/getTeacherResultsAloneBySchoolYear';
            	axios.post(url,senddata,{cancelToken: this.source.token}).then(function(response) {
					if(response.data.success == true){
//						console.log(response.data.data)
						self.linedata.xAxis.data = response.data.data.Subject;
						self.linedata.series = response.data.data.Subject_data;
						self.drawLine()
	            	}else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
	            	}
				})
				.catch(function(thrown) {
//					if (axios.isCancel(thrown)) {
//					    //console.log('Request canceled', thrown.message);
//					}else{
//						self.$Message.error('系统发生错误123');
	//					self.chartshow = false;
//					}
				});
			},
			
            //获取老师列表
           	getteacherlist:function(){
				let sessionroleid = getsessionstorage('roleid');
				
				var senddata = {
					"type":"Middle",
					"schoolYear":this.studyYearSelect,
					"adName":this.subjectselect,
					"roleId":sessionroleid,
				}
				
				if(sessionroleid){
					var self = this;
	            	let url = api.apidomain+'/tqes/web/quaTeacherResults/getTeacherBySchoolYear';
	            	this.$http.post(url,senddata).then(function(response) {
						if(response.data.success == true){
							
//		            		console.log(response.data.data)
							self.teacherlist = response.data.data
							if(self.teacherlist.length != 0){
								self.teacherselect = self.teacherlist[0].value
								self.getsinglelinechartdata();
							}else{
								self.teacherselect = '';
								let myChart = self.$echarts.init(self.$refs.line,'hengyi')
				                myChart.clear();
//				                myChart.setOption(self.linedata);
							}
							
			           }else if(response.data.success == false){
			            		self.$Message.error({
					                content: response.data.msg,
					                duration: 5
					            });
			            	}
			            })
						.catch(function(error) {
							self.$Message.error({
							content: '系统发生错误：错误码00223',
							duration: 10,
							closable: true
						});
						});
				}else{
					self.$Message.error({
							content: '系统发生错误：错误码00224',
							duration: 10,
							closable: true
						});
				}
			},
//			
       },
		destroyed(){
			if(this.subjectlist.length != 0){
				this.source.cancel()
			}
		}
    }
</script>

<style lang="css" scoped>
	.indexshow >>> .ivu-select-single .ivu-select-selection{
		/*border: none;
    	border-radius: 0px*/
	}
	.indexshow >>> .active{
		background-color: #517EDB;
		color: white;
	}
</style>